var performanceS = function (salary) {
    return salary * 4;
}
var performanceA = function (salary) {
    return salary * 3;
}
var performanceB = function (salary) {
    return salary * 2;
}


var calculateBonus = function (level, salary) {
    if (level === "s") {
        return performanceS(salary);
    }
    if (level === "a") {
        return performanceA(salary);
    }
    if (level === "b") {
        return performanceB(salary);
    }
};
calculateBonus("s", 30000);

// 策略模式：可以灵活的扩展策略，新增的策略不会影响到之前的策略。达到一个目标有不同的途径
// 模板模式：定制一个执行的轨迹，可以对这个轨迹中的某些部分进行定制
var strategies = {
    s: function (salary) {
        return salary * 4;
    },
    a: function (salary) {
        return salary * 3;
    },
    b: function (salary) {
        return salary * 2;
    }
}
var calculateBonus = function (level, salary) {
    return strategies[level](salary);
}